<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'MyJsp.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
strong {
	font-size: 15px;
}

pre {
	padding: 16px 0;
	line-height: 1.45;
	background-color: #f6f8fa;
	border-radius: 3px;
}
</style>

<script type="text/javascript" src="jQuery/jquery-3.3.1.js"></script>

<script type="text/javascript">
	function add() {
		$.ajax({
			url : "${pageContext.request.contextPath}/AddServlet",
			data : {
				"categoryid" : $("#categoryid").val(),
				"title" : $("#title").val(),
				"summary" : $("#summary").val(),
				"uploadMan" : $("#uploadMan").val(),
				"date2" : $("#date2").val()
			},
			type : "post",
			dataTyppe : "json",
			success : function(result) {
				if (result.code == 0) {
					$("#categoryid").val("");
					$("#title").val("");
					$("#summary").val("");
					$("#uploadMan").val("");
					$("#date2").val("");
				}
				if (confirm(result.msg + "是否继续添加")) {

				} else {
					location.href = "${pageContext.request.contextPath}/EbookServlet";
				}

			},
			error : function() {
				alert("xx");
			}
		})



	}
	
	function Return(){
	location.href="${pageContext.request.contextPath}/EbookServlet"
	}
	
</script>
</head>

<body>



	<div class="container">
		<div class="row clearfix">
			<div class="col-md-12 column">
				<h3 class="text-center">增加电子图书</h3>
				<form action="${pageContext.request.contextPath }/AddServlet"
					method="post" id="form">
					<input type="hidden" value="${param.categoryid }" name="categoryid"
						id="categoryid">
					<table class="table table-bordered table-hover">
						<tr>
							<td>图书名称：</td>
							<td><input type="text" name="title" requierd="requierd"
								id="title"></td>
						</tr>
						<tr>
							<td>图书摘要:</td>
							<td><textarea style="height: 200px;width: 500px"
									name="summary" id="summary"></textarea></td>
						</tr>
						<tr>
							<td>上传人</td>
							<td><input type="text" name="uploadMan" requierd="requierd"
								id="uploadMan"></td>
						</tr>
						<tr>
							<td>上传时间</td>
							<td><input type="text" name="date" requierd="requierd"
								id="date2"
								data-options="{'type':'YYYY-MM-DD','beginYear':2010,'endYear':2088}"
								style="width:166px;height:19px;"></td>
						</tr>
						<tr>
							<td></td>
							<td><input type="button" onclick="add();" value="添加"><input
								type="button" value="返回首页" onclick="Return();"></td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</div>


	<script src="js/jquery.min.js"></script>
	<script src="js/jquery.date.js"></script>
	<script>
	
		$.date('#date2');
	</script>




</body>
</html>
